import React from "react";
import { useState } from "react";
export default function Test1() {
  const [n, setN] = useState(0); //使用一个状态，该状态的默认值是0
  return (
    <>
      <h1>Test1</h1>
      <div>
        <button
          onClick={() => {
            setN(n - 1);
          }}
        >
          -
        </button>
        <span>{n}</span>
        <button
          onClick={() => {
            setN(n + 1);
          }}
        >
          +
        </button>
      </div>
    </>
  );
}
